package com.example.demo;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;
import cn.hutool.captcha.LineCaptcha;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController

public class HuToolCaptchaController {
    @RequestMapping("/captcha")
    public void getcaptcha(HttpServletResponse httpSession) throws IOException {
        LineCaptcha captcha = CaptchaUtil.createLineCaptcha(100, 60);
        httpSession.setContentType("image/png");
        captcha.write(httpSession.getOutputStream());
        httpSession.getOutputStream().close();
    }
}
